<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
    <link rel="stylesheet" type="text/css" href="../../lib/laydate.css"/>
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link rel="stylesheet" type="text/css" href="../../css/dept/deptManagement.css"/>
    <link rel="stylesheet" type="text/css" href="../../lib/easyui/themes/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="../../lib/easyui/themes/icon.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/news/center.css"/>
    <link rel="stylesheet" type="text/css" href="../../lib/laydate.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/dept/new_news.css"/>
    <script type="text/javascript" src="../../js/jquery/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="../../js/base/base.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="../../lib/laydate/laydate.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <title>权限设置</title>
    <style>

        #search {
            margin-left: 360px;
            font-size: 16px;
        }

        #export {
            font-size: 16px;
        }

        .newNew tr td {
            border: none;
        }

        .newNew .tableHead tr td {
            border: 1px solid #c0c0c0;
        }

        .ban {
            width: 80px;
            height: 28px;
            padding-left: 10px;
        }

        .left {
            float: left;
        }

        .new_but {
            width: 130px;
            background: #2F8AE3;
            height: 28px;
            line-height: 28px;
            border-radius: 4px;
            margin-left: 0px;
            padding-left: 4px;
            cursor: pointer;
            color: #fff;
        }

        .close_but {
            width: 50px;
            height: 37px;
            margin-left: 0px;
            line-height: 28px;
            border-radius: 4px;
            padding-left: 4px;
            cursor: pointer;
            /*color:#fff;*/
        }

        .box {
            width: 300px;
            height: 150px;
            text-align: center;
            font-size: 20px;
            color: #fff;
            background: #2F8AE3;
            margin: 0 auto;
            line-height: 150px;
        }

        .success {
            text-align: center;
            display: none;
        }

        .box {
            margin-bottom: 30px;
        }

        .success span {
            width: 132px;
            height: 35px;
            background-color: rgba(224, 224, 224, 0.61);
            font-size: 16px;
            border-radius: 5px;
            padding-left: 8px;
            cursor: pointer;

            line-height: 30px;
            display: inline-block;
        }

        #clearSave {
            background: url(../../img/vote/clearsave.png) no-repeat;
            background-size: 181px;
            color: #fff;
            width: 181px;
            font-size: 16px;
            height: 30px;
            cursor: pointer;
            line-height: 30px;
            padding-left: 22px;
        }

        #save {
            background: url(../../img/vote/saveBlue.png) no-repeat;
            color: #fff;
            line-height: 30px;
            font-size: 16px;
            width: 91px;
            height: 30px;
            cursor: pointer;
            padding-left: 11px;

        }

        #refull {
            color: #000;
            width: 87px;
            line-height: 30px;
            height: 30px;
            cursor: pointer;
            font-size: 16px;
            background: url("../../img/vote/new.png") no-repeat;
            padding-left: 12px;

        }

        #addItem, #addChild {
            background: url(../../img/vote/save.png) no-repeat;
            color: #fff;
            width: 142px;
        }

        #addChild {
            background: url(../../img/vote/save.png) no-repeat;
            color: #fff;
        }

        #back {
            display: inline-block;
            width: 78px;
            height: 38px;
            line-height: 30px;
            cursor: pointer;
            border-radius: 3px;
            background: url(../../img/edu/eduSchoolCalendar/back.png) no-repeat;
            padding-left: 7px;
            font-size: 14px;
        }

        .laydate-footer-btns {
            position: absolute;
            right: 69px;
            top: 10px;
        }

        .layui-laydate-content {
            margin-left: 33px;
        }

        table tbody tr td {
            font-size: 11pt !important;
        }

        a {
            color: #1772c0;
        }
        .blue_text{
            width: 200px;
        }
    </style>
</head>
<body style="overflow:scroll;overflow-y: auto;overflow-x:hidden;">

<%--学生信息列表--%>

<div class="step1" style="display: block;margin-left: 10px;">

    <div class="nav_box clearfix">
        <div class="nav_t1"><img src="/img/commonTheme/${sessionScope.InterfaceModel}/icon_noticeMang.png"></div>
        <div class="nav_t2" class="news">权限设置</div>
    </div>
    <table class="newNews">
        <tbody>
        <tr>
            <td class="blue_text" >
                删除权限:
            </td>
            <td>
                <textarea name="" id="delete" user_id="" style="width: 400px;height: 80px" disabled></textarea>
                <a href="javascript:;" id="delete_pop" style="color:#1772c0"><fmt:message code="global.lang.add"/></a>
                <a href="javascript:;" class="clearTwo" style="color:#1772c0" onclick="delete_pop()"><fmt:message
                        code="global.lang.empty"/></a>
            </td>
        </tr>
        <tr>
            <td class="blue_text">
                编辑权限:
            </td>
            <td>
                <textarea name="" id="edit" user_id="" style="width: 400px;height: 80px" disabled></textarea>
                <a href="javascript:;" id="edit_pop" style="color:#1772c0"><fmt:message code="global.lang.add"/></a>
                <a href="javascript:;" class="clearTwo" style="color:#1772c0" onclick="edit_pop()"><fmt:message
                        code="global.lang.empty"/></a>
            </td>
        </tr>
        </tbody>
        <div>
            <tr style="text-align:center">
                <td colspan="2">
                    <button type="button" class="close_but" id="save" onclick="save()"><fmt:message code="global.lang.save"/></button>
                    <button type="button" class="close_but" id="refull" onclick="clearAll()"><fmt:message
                            code="global.lang.refillings"/></button>
                </td>
            </tr>
        </div>
    </table>
    <div class="success">
        <div class="box"><fmt:message code="vote.th.successfullySaved"/>!</div>
        <div>
            <span id="addItem"><fmt:message code="vote.th.AddVotingItems"/></span>
            <span id="addChild"><fmt:message code="vote.th.AddSubVoting"/></span>
            <span id="back"><fmt:message code="notice.th.return"/></span>
        </div>
    </div>
</div>

</body>

<script type="text/javascript">
    var user_id = '';
    $("#delete_pop").on("click", function () {//选人员控件
        user_id = 'delete';
        $.popWindow("../../common/selectUser");
    });
    $("#edit_pop").on("click", function () {//选人员控件
        user_id = 'edit';
        $.popWindow("../../common/selectUser");
    });
    function delete_pop() {
        $('#delete').removeAttr('user_id');
        $('#delete').removeAttr('user_id');
        $('#delete').attr('user_id', '');
        $('#delete').val('');
    }
    function edit_pop() {
        $('#edit').removeAttr('user_id');
        $('#edit').removeAttr('user_id');
        $('#edit').attr('user_id', '');
        $('#edit').val('');
    }
    //清空所有内容
    function clearAll() {
        delete_pop();
        edit_pop();
    }
        //新建保存
        function save() {
            var data={
                delUser:$('#delete').attr('user_id'),
                editUser:$('#edit').attr('user_id'),
            }
            console.log(data)
            $.ajax({
                url: '/crmRole/setUpCrmRole',
                type: 'post',
                dataType: 'json',
                data:data,
                success: function (data) {
                    if(data.flag){
                        layer.msg('保存成功！',{icon:1},function () {

                        });/*添加成功*/
                    }else{
                        layer.msg('保存失败！',{icon:2});/*添加失败*/
                    }
                },
                error: function (data) {
                    layer.msg('保存失败！',{icon:2});/*添加失败*/
                }
            })
    }
    $(function () {
        $.ajax({
            url: '/crmRole/selectAll',
            type: 'get',
            dataType: 'json',
            success: function (json) {
                if (json.flag) {
                    for(var i=0;i<=json.object.length;i++){
                        $('#edit').val(json.object[i].editUserName);
                        $('#edit').attr('user_id', json.object[i].editUser);
                        $('#delete').val(json.object[i].delUserName);
                        $('#delete').attr('user_id', json.object[i].delUser);
                    }
                }
            }
        })
    })
</script>
</html>
